package edums.common.model.dao;

import java.sql.SQLException;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import edums.common.dto.UsersDTO;

public class UsersDAOImpl implements UsersDAO {
	
	private SqlMapClientTemplate client;

	public void setSqlMapClient(SqlMapClientTemplate client) {
		this.client = client;
	}

	@Override
	public UsersDTO selectUserInfo(UsersDTO usersDTO) throws SQLException {
		return (UsersDTO)client.queryForObject("users.selectUserInfo", usersDTO);
	}
	
	
	@Override
	public int selectUserCountById(String userId) throws SQLException {
		return (Integer)client.queryForObject("users.selectUserCountById", userId);
	}
	
	@Override
	public Object insertUsers(UsersDTO usersDTO) throws SQLException {
		return client.insert("users.insertUsers", usersDTO);
	}
	
	@Override
	public int updatePassword(UsersDTO usersDTO) throws SQLException {
		return (Integer)client.update("users.updateUsersPassword", usersDTO);
	}
	
	@Override
	public int updateEnabled(HashMap paramMap) throws SQLException {
		return client.update("users.updateEnabled", paramMap);
	}
	
	@Override
	public int deleteUsers(String userId) throws SQLException {
		return client.delete("users.deleteUsers", userId);
	}
	
	@Override
	public String selectUserByPassword(String userId) throws SQLException {
		return (String)client.queryForObject("users.selectUserByPassword", userId);
	}
}
